package day05;

import java.util.Random;

public class Main {
    public static void main(String[] args) {
        Student[] students = new Student[5];
        Random random = new Random();

        for (int i = 0; i < students.length; i++) {
            String studentId = "XXXXXXXX";
            String name = "Student" + (i + 1);
            char gender = (char) (random.nextInt(2) == 0 ? 'M' : 'F');
            int age = random.nextInt(25) + 18;

            String department = random.nextBoolean() ? (random.nextBoolean() ? "english" : "computer") : "literature";

            Student student;
            switch (department) {
                case "english":
                    student = new EnglishStudent(studentId, name, gender, age);
                    setEnglishStudentScores(student, random);
                    break;
                case "computer":
                    student = new ComputerStudent(studentId, name, gender, age);
                    setComputerStudentScores(student, random);
                    break;
                case "literature":
                    student = new LiteratureStudent(studentId, name, gender, age);
                    setLiteratureStudentScores(student, random);
                    break;
                default:
                    throw new IllegalArgumentException("Invalid department: " + department);
            }

            students[i] = student;
        }

        for (Student student : students) {
            System.out.println(student);
        }
    }

    private static void setEnglishStudentScores(Student student, Random random) {
        EnglishStudent englishStudent = (EnglishStudent) student;
        englishStudent.setSpeechScore(random.nextInt(41) + 60);
        englishStudent.setFinalExamScore(random.nextInt(41) + 60);
        englishStudent.setMidExamScore(random.nextInt(41) + 60);
    }

    private static void setComputerStudentScores(Student student, Random random) {
        ComputerStudent computerStudent = (ComputerStudent) student;
        computerStudent.setProgrammingScore(random.nextInt(41) + 60);
        computerStudent.setProjectScore(random.nextInt(41) + 60);
        computerStudent.setFinalExamScore(random.nextInt(41) + 60);
    }

    private static void setLiteratureStudentScores(Student student, Random random) {
        LiteratureStudent literatureStudent = (LiteratureStudent) student;
        literatureStudent.setEssayScore(random.nextInt(41) + 60);
        literatureStudent.setMidExamScore(random.nextInt(41) + 60);
        literatureStudent.setFinalExamScore(random.nextInt(41) + 60);
    }
}